import React from "react";
import './index.css';
import img from "./img.png";

class Subject extends React.Component{
  state = {
    goodsLists: []
  }
  render(){
    return(
      <div>

      
        <ul className="clearfix">
          {
            this.state.goodsLists.map(item => {
              return (
                <li className="with-pms">
             <div className="img-loaded">
                <img src={item.imgSrc} alt="" />
             </div>
             <div className="info">
               <div className="tag-wrap"></div>
               <div className="name-wrap">
                 <span>相宜本草</span>
                 <i>男士洁面乳120g*2两只装深层清洁清爽控油男士洗面奶 以实物为准</i>
               </div>
               <div className="price-wrap">
                 <span className="price"><i>￥</i>46</span>
                 <span className="market-price"><i>￥</i>78</span>
                 <em className="iconfont icon-taobaogouwuche_ios"></em>
               </div>
             </div>
          </li>
              )
            })
          }
          
        </ul>
      <div className="car">
        <a href="/">
          <div className="cart-wrap">
            <i className="iconfont icon-taobaogouwuche_ios"></i>
            <span className="num"></span>
          </div>
        </a>
      </div>
      <div className="first-page">
        <a href="/">
          <i className="iconfont icon-shouye"></i>
        </a>
      </div>
     </div>
    )
  }
  componentDidMount() {
    fetch(' http://localhost:3000/details', {
      headers: {
        "Content-Type": "application/json"
      }
    })
    .then(response => {
      return response.json()
    }).then(res => {
      this.setState({
        goodsLists: res.goodsList
      })
      console.log(res, this.state)
    })
  }
};

export default Subject;
